package com.atguigu.customer.mapper;


import com.atguigu.customer.bean.Customer;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
@DS("dga")
public interface CustomerMapper extends BaseMapper<Customer> {


    @Insert("insert into customer(id,name,age) values(#{cus.id},#{cus.name},#{cus.age})")
    void saveCustomer(@Param("cus") Customer customer);

    @Select("select id,name,age from customer where id=#{id}")
    Customer  getCustomerById(@Param("id") Integer id);

    @Select("select id,name,age from customer where name like  '%${name}%'")
    List<Customer> getCustomerByName(@Param("name") String name);


}
